<template>
  <div id="app">
        <router-view v-if="isRouterAlive"/>
        <fooers></fooers>
  </div>
</template>

<script>
  import fooers from "@/components/public/fooer"

  export default {
    components: {
      fooers,
    },
    name: 'App',
    data(){
      return{
        isRouterAlive:true
      }
    },
    provide(){
     return{
       reload:this.reload
     }
    },
    methods:{
      reload(){
        this.isRouterAlive = false;
        this.$nextTick(()=> {
          this.isRouterAlive = true;
        })
      }
    },

    mounted(){

      let stoorageLang = sessionStorage.sitename;
      let lang = '';
      if (stoorageLang === undefined){
        lang = navigator.language || navigator.userLanguage;
        lang = lang.substr(0,2);
        if(lang !== 'zh'){
          lang = 'en';
        }else {
          lang = 'cn'
        }
        sessionStorage.sitename = lang;
      }
      this.$i18n.locale = sessionStorage.sitename;


      if(!sessionStorage.sitename){
          document.title = 'purse';
        }else if(sessionStorage.sitename == 'cn'){
          document.title = '派实';
        }else {
          document.title = 'purse';
        }

      if(sessionStorage.url=== undefined){
        this.$router.push('/');
      }else {
        var a = JSON.parse(sessionStorage.url);
        this.$router.push(a);
      }
    }
  }
</script>

<style>

</style>
